package com.fg.cloud.manager.service.agency.impl;

import java.util.ArrayList;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.fg.cloud.common.PageUtils;
import com.fg.cloud.manager.entry.BaseEntity;
import com.fg.cloud.manager.entry.agency.AgencyFavoritesEntity;
import com.fg.cloud.manager.mapper.BaseMapper;
import com.fg.cloud.manager.mapper.agency.AgencyFavoritesMapper;
import com.fg.cloud.manager.service.BaseServiceImpl;
import com.fg.cloud.manager.service.agency.AgencyFavoritesService;

@Service
public class AgencyFavoritesServiceImpl extends BaseServiceImpl implements AgencyFavoritesService {

	@Autowired
	private AgencyFavoritesMapper agencyFavoritesMapper;
	
	@Override
	protected <T extends BaseEntity> BaseMapper getBaseMapper() {	
		return agencyFavoritesMapper;
	}

	/**
	 * 动态查询
	 */
	@Override
	public boolean selectByCondition(AgencyFavoritesEntity searchEntity) {
		
		return agencyFavoritesMapper.selectByCondition(searchEntity) > 0 ? true : false;
	}

	/**
	 * 批量删除
	 */
	@Override
	public Integer deletes(Long facId, Long[] ids) {
		
		return agencyFavoritesMapper.deletes(facId, ids);
	}

	@Override
	public void selectforPage(PageUtils<AgencyFavoritesEntity> pageinfo) {
		long total = agencyFavoritesMapper.filterCount(pageinfo.getCondition());
		pageinfo.setTotal(total);
		if (total>0) {
			pageinfo.setData(agencyFavoritesMapper.findList(pageinfo));
		} else {
			pageinfo.setData(new ArrayList<AgencyFavoritesEntity>());
		}
	}

}
